using System.Web;

namespace Tools.Utilities
{
    /// <summary>
    /// Utility class for user cookies.
    /// </summary>
    public static class CookieManager
    {
        /// <summary>
        /// Gets cookie value from request.
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public static string Get(string paramName, string defaultValue)
        {
            if (HttpContext.Current.Request.Cookies.Get(paramName) != null)
            {
                return HttpContext.Current.Request.Cookies.Get(paramName).Value;
            }
            else
            {
                return defaultValue;
            }
        }

        /// <summary>
        /// Sets cookie value.
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="value"></param>
        public static void Set(string paramName, string value)
        {
            HttpContext.Current.Response.Cookies.Add(new HttpCookie(paramName, value));
        }

        /// <summary>
        /// Removes cookie value.
        /// </summary>
        /// <param name="paramName"></param>
        public static void Remove(string paramName)
        {
            HttpContext.Current.Response.Cookies.Remove(paramName);
        }
    }
}